package com.gec.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gec.service.UserService;
import com.gec.service.impl.UserServiceImpl;

@WebServlet("/delete.action")
public class DeleteUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//接收用户的id 
		String sid = request.getParameter("id");
		
		// !"".equals(sid) 防止空指针
		if(!"".equals(sid) && sid != null) {
			Integer id = Integer.parseInt(sid);
			//创建userservice的实例
			UserService service = new UserServiceImpl();
			
			//调用delete
			service.delete(id);
		}
		
		//客户端跳转
		response.sendRedirect("usercontrol.action");
	}

}
